home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / sbprolog / amiga / v3_1 / sbp3_1e.lzh / SCREEN.PL < prev    next >
Text File  |  1991-10-31  |  4KB  |  112 lines

  1. /* From the book PROLOG PROGRAMMING IN DEPTH
  2.    by Michael A. Covington, Donald Nute, and Andre Vellino.
  3.    Copyright 1988 Scott, Foresman & Co.
  4.    Non-commercial distribution of this file is permitted. */
  5.  
  6. /* SCREEN.PL */
  7. /* Screen control using ANSI escape sequences */
  8.  
  9. /* These predicates work on the IBM PC if the
  10.  * ANSI.SYS device driver is installed -- see text.
  11.  * Except as noted below, they also work on the
  12.  * DEC VT-100 and similar terminals on any computer.
  13.  */
  14.  
  15. /************************************************
  16.  * clrscr                                       *
  17.  *  Clears the screen and homes the cursor but  *
  18.  *  does not change video attribute settings.   *
  19.  ************************************************/
  20.  
  21. clrscr :- put(27),
  22.           write('[2J').
  23.  
  24. /***************************************
  25.  * home                                *
  26.  *  Moves the cursor to the upper left *
  27.  *  corner of the screen.              *
  28.  ***************************************/
  29.  
  30. home :- put(27),
  31.         write('[H').
  32.  
  33. /*********************************************
  34.  * clreol                                    *
  35.  *  Clears from the current cursor position  *
  36.  *  to the end of the line.                  *
  37.  *********************************************/
  38.  
  39. clreol :- put(27),
  40.           write('[K').
  41.  
  42. /********************************************************
  43.  * gotoxy(X,Y)                                          *
  44.  *  Puts cursor at row X, column Y (numbered from 1,1). *
  45.  ********************************************************/
  46.  
  47. gotoxy(X,Y) :- integer(X),
  48.                integer(Y),
  49.                put(27),
  50.                write('['),
  51.                write(X),
  52.                write(';'),
  53.                write(Y),
  54.                write('H').
  55.  
  56. /************************************************************
  57.  * video(Mode)                                              *
  58.  *  Sets various video modes.                               *
  59.  *  Underlined or Reverse can be combined                   *
  60.  *  with Intense and/or Blinking.                           *
  61.  *  Underlining works on the VT-100 and the IBM Monochrome  *
  62.  *  Display but not the various IBM color displays.         *
  63.  ************************************************************/
  64.  
  65. video(normal)     :- videoattribute(0).
  66. video(underlined) :- videoattribute(4).
  67. video(intense)    :- videoattribute(1).
  68. video(reverse)    :- videoattribute(7).
  69. video(blinking)   :- videoattribute(5).
  70.  
  71. /*************************************************************************
  72.  * fcolor(Color)                                                         *
  73.  *  Changes the foreground color (the color of lettering on the screen). *
  74.  *  For IBM and similar color displays.                                  *
  75.  *************************************************************************/
  76.  
  77. fcolor(black)   :- videoattribute(30).
  78. fcolor(red)     :- videoattribute(31).
  79. fcolor(green)   :- videoattribute(32).
  80. fcolor(yellow)  :- videoattribute(33).
  81. fcolor(blue)    :- videoattribute(34).
  82. fcolor(magenta) :- videoattribute(35).
  83. fcolor(cyan)    :- videoattribute(36).
  84. fcolor(white)   :- videoattribute(37).
  85.  
  86. /***********************************************************************
  87.  * bcolor(Color)                                                       *
  88.  *  Changes the background color (color of blank space on the screen). *
  89.  *  For IBM and similar color displays.                                *
  90.  ***********************************************************************/
  91.  
  92. bcolor(black)   :- videoattribute(40).
  93. bcolor(red)     :- videoattribute(41).
  94. bcolor(green)   :- videoattribute(42).
  95. bcolor(yellow)  :- videoattribute(43).
  96. bcolor(blue)    :- videoattribute(44).
  97. bcolor(magenta) :- videoattribute(45).
  98. bcolor(cyan)    :- videoattribute(46).
  99. bcolor(white)   :- videoattribute(47).
  100.  
  101. /**************************************************************
  102.  * videoattribute(N)                                          *
  103.  *  Uses the ANSI "set graphics rendition" escape sequence to *
  104.  *  request the display attributes denoted by the number N.   *
  105.  *  Called by BCOLOR, FCOLOR, and VIDEO.                      *
  106.  **************************************************************/
  107.  
  108. videoattribute(X) :- put(27),     /* Escape */
  109.                      write('['),
  110.                      write(X),
  111.                      write('m').
  112.